package com.fxh.singlereponsibility;

import javax.swing.*;

public class SingleResponsibility1 {

    public static void main(String[] args) {
        Vehicle vehicle = new Vehicle();
        vehicle.run("SUV");
        AirVerhicle verhicle1 = new AirVerhicle();
        verhicle1.run("飞机");
        WaterVerhicle verhicle3 = new WaterVerhicle();
        verhicle3.run("摩托车");

    }
}


//交通工具类
//方式1：run方法违反了单一职责原则
//解决方法非常简单，根据交通工具运行不同方法，分解为不同类即可
//
class Vehicle{

    public void run(String vehicle){
        System.out.println(vehicle +"在公路上运行");
    }
}